<%@page import="clientLogin.JDBCClientDAO"%>
<%@page import="clientLogin.Client"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>PersonalCentre</title>

<script type="text/javascript" src="jquery-1.8.3.js"></script>
<script type="text/javascript">
	$(document).ready(function(){
		$.ajax({
			url: "SessionsClientServlet",
			type: "POST",
			success:function(data){
				$('#myCourses').html(data);
			},
			error: function(e){
				console.text(e.message);
			}
		});
		
		$("input[type='button']").click(function(){
			var textField = $(this).attr("class");
			$("input[type='text']").each(function(){
				if($(this).attr("class") == textField){
					$(this).removeAttr("readonly");
				}
			});
		});
	});	
</script>

</head>
<body>
<h2>Your personal informations are:</h2>
<% 
	JDBCClientDAO DAO = new JDBCClientDAO();
	int clientID = Integer.parseInt(request.getSession().getAttribute("clientID").toString());
	Client client = new Client();
	client = DAO.getByID(clientID);
	String lastname = client.getLastname();
	String firstname = client.getFirstname();
	String address = client.getAddress();
	String phone = client.getPhone();
	String email = "&nbsp;";
	String password = client.getPwd();
	if(!client.getEmail().equals("")){
		email = client.getEmail();
	}	
%>
<form action="MAJPersonalInfoServlet" method="POST" id="myInfos">
Your last name :<br/><input type="text" name="lastname" value=<%=lastname%> class="lastname" readonly /><input type="button" name="lastname" value="Edit" class="lastname"/><br/>
Your first name :<br/><input type="text" name="firstname" value=<%=firstname%> class="firstname" readonly /><input type="button" name="firstname" value="Edit" class="firstname"/><br/>
Your address :<br/><input type="text" name="address" value=<%=address%> class="address" readonly /><input type="button" name="Edit" value="Edit" class="address"/><br/>
Your phone :<br/><input type="text" name="phone" value=<%=phone%> class="phone" readonly /><input type="button" name="Edit" value="Edit" class="phone"/><br/>
Your email :<br/><input type="text" name="email" value=<%=email%> class="email" readonly /><input type="button" name="Edit" value="Edit" class="email"/><br/>
<input type="submit" name="Valide" value="Valid" />
</form>
<br/>
Reset your password:<form action="ResetPWD.html"><input type="submit" name="Reset" value="Reset" /></form><br/>

<div id="myCourses">

</div>

Return to the home page: <form action="homePage.jsp"><input type="submit" name="Return" value="Return" /></form><br/>
</body>
</html>